<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml"
                xmlns:security="http://www.springframework.org/security/tags"

>
    <ui:define name="title">合利宝-信用卡代偿、取现 统计后台</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"
                                         />
                        <p:columnToggler datasource="CreditCompensatoryOrderDataTable" trigger="toggler"
                                         />
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         rendered="#{creditCompensatoryWithdrawStatListBean.isNormal() }"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         rendered="#{security:areAllGranted('COMPENSATION_ORDER_EXPORT')}"
                                         ajax="false">
                            <p:dataExporter type="xls" target="CreditCompensatoryOrderDataTable" fileName="export"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;">

                                <p:outputLabel for="startDate" value="开始日期"/>
                                <p:calendar id="startDate" value="#{creditCompensatoryWithdrawStatListBean.$.startDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="endDate" value="结束日期"/>
                                <p:calendar id="endDate" value="#{creditCompensatoryWithdrawStatListBean.$.endDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="product_id" value="产品"/>
                                <p:selectOneMenu id="product_id" value="#{creditCompensatoryWithdrawStatListBean.$.product_id}"
                                				 filter="true" filterMatchMode="contains">
                                     <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                   	 <f:selectItems
                                            value="#{creditCompensatoryWithdrawStatListBean.commProductIds}"
                                            var="product"
                                            itemLabel="#{product.name}" itemValue="#{product.productId}"/>
                                </p:selectOneMenu>


                                <p:outputLabel for="channel_id" value="渠道"/>
                                    <p:selectOneMenu id="channel_id" filter="true" filterMatchMode="startsWith"  value="#{creditCompensatoryWithdrawStatListBean.$.channel_id}">
                                        <f:selectItem itemLabel="全部" itemValue="" />
                                        <f:selectItems value="#{creditCompensatoryWithdrawStatListBean.getCommProductChannels()}"
                                                       var="commChannel"
                                                       itemLabel="#{commChannel.channelName}"
                                                       itemValue="#{commChannel.channelCode}"/>
                                    </p:selectOneMenu>

                                <p:outputLabel for="orderType" value="订单类型"/>
                                <p:selectOneMenu id="orderType" value="#{creditCompensatoryWithdrawStatListBean.$.orderType}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="代偿" itemValue="0" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="取现" itemValue="1" noSelectionOption="true"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="channel_from" value="入口"/>
                                <p:inputText id="channel_from" value="#{creditCompensatoryWithdrawStatListBean.$.channel_from}" style="width:100%"/>

                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="CreditCompensatoryOrderDataTable"
                                         style="width: 100%"
                                         update="@form"
                                         var="record"
                                         value="#{creditCompensatoryWithdrawStatListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="97%"
                                         reflow="true"
                                         selection="#{creditCompensatoryWithdrawStatListBean.selectedRecords}"
                                         resizableColumns="true"
                                         >

                                <p:column headerText="日期">
                                    <h:outputText value="#{record.time}"/>
                                </p:column>
                                <p:column headerText="产品">
                                    <h:outputText value="#{creditCompensatoryWithdrawStatListBean.translateProduct(record.prdocu_id)}"/>
                                </p:column>
                                <p:column headerText="渠道">
                                    <h:outputText value="#{creditCompensatoryWithdrawStatListBean.translateProductChannel(record.channel)}"/>
                                </p:column>
                                <p:column headerText="入口id">
                                    <h:outputText value="#{record.channel_from}"/>
                                </p:column>
                                <p:column headerText="订单类型">
                                    <h:outputText value="#{record.orderType}"/>
                                </p:column>
                                <p:column headerText="首页uv">
                                    <h:outputText value="#{record.home_uv}"/>
                                </p:column>
                                <p:column headerText="一级卡页UV">
                                    <h:outputText value="#{record.one_page_uv}"/>
                                </p:column>
                                <p:column headerText="二级卡页UV">
                                    <h:outputText value="#{record.two_page_uv}"/>
                                </p:column>
                                <p:column headerText="订单确认框UV">
                                    <h:outputText value="#{record.confirm_uv}"/>
                                </p:column>
                                <p:column headerText="提交订单数">
                                    <h:outputText value="#{record.commit_pv}"/>
                                </p:column>
                                <p:column headerText="扣款成功UV">
                                    <h:outputText value="#{record.paySuccessUV}"/>
                                </p:column>
                                <p:column headerText="到账成功UV">
                                    <h:outputText value="#{record.withdrawSuccessUV}"/>
                                </p:column>
                                <p:column headerText="收入">
                                    <h:outputText value="#{record.income}"/>
                                </p:column>

                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
